<html xmlns="http://www.w3.org/1999/xhtml"
	xmlns:f="http://java.sun.com/jsf/core"
	xmlns:h="http://java.sun.com/jsf/html"
	xmlns:ui="http://java.sun.com/jsf/facelets"
	xmlns:p="http://primefaces.org/ui">
<h:body>

	<ui:composition template="/pages/template/layout01.xhtml">

		<ui:define name="content">

			<h:messages globalOnly="true" />

			<h:form id="formPesquisa" rendered="#{!responsavelBean.editMode}">

				<ul>

					<li><p:commandLink value="Adicionar Responsavel"
							actionListener="#{responsavelBean.create}" ajax="false" /></li>
				</ul>

				<h:panelGrid columns="1">
					<h1>Responsavel</h1>
					<h:panelGroup>
						<h:outputText value="Filtro:" />
						<p:inputText maxlength="30" size="30"
							value="#{responsavelBean.nomeResponsavel}">
							<f:ajax event="keyup" render="resultados"
								listener="#{responsavelBean.filtrarResponsavel}" />
						</p:inputText>
					</h:panelGroup>
				</h:panelGrid>
				<p:dataTable value="#{responsavelBean.responsavels}"
					var="responsavel" id="resultados" border="1">
					<p:column id="clRespCodigo">
						<f:facet name="header">ID</f:facet>
						<h:outputText value="#{responsavel.respCodigo}" />
					</p:column>
					<p:column id="clPessoa">
						<f:facet name="header">Nome da Responsavel</f:facet>
						<h:outputText value="#{responsavel.pessoa.pessoNome}" />
					</p:column>
					<p:column id="clFuncao">
						<f:facet name="header">Funcao</f:facet>
						<h:outputText value="#{responsavel.funcao.funcDescricao}" />
					</p:column>
					<p:column id="clBloco">
						<f:facet name="header">Bloco</f:facet>
						<h:outputText value="#{responsavel.bloco.strResBlo}" />
					</p:column>
					<p:column id="clResInicio">
						<f:facet name="header">Data Inicial</f:facet>
						<h:outputText value="#{responsavel.respInicio}" />
					</p:column>
					<p:column id="clResFim">
						<f:facet name="header">Data Fim</f:facet>
						<h:outputText value="#{responsavel.respFim}" />
					</p:column>
					<p:column id="alterar">
						<f:facet name="header">#</f:facet>
						<h:commandLink value="Alterar" action="#{responsavelBean.update}">
							<f:setPropertyActionListener
								target="#{responsavelBean.responsavel}" value="#{responsavel}" />
						</h:commandLink>
					</p:column>
					<p:column id="excluir">
						<f:facet name="header">#</f:facet>
						<p:commandLink id="lnkDelete" value="Excluir"
							onclick="if (!confirm('Tem certeza que deseja excluir este dado?')) return false"
							action="#{responsavelBean.delete}" ajax="false">
							<f:setPropertyActionListener
								target="#{responsavelBean.responsavel}" value="#{responsavel}" />
						</p:commandLink>
					</p:column>
				</p:dataTable>
			</h:form>
			<h:form id="formEdicao" rendered="#{responsavelBean.editMode}">
				<h:panelGrid columns="2">

					<h:outputText value="Pessoa:" />
					<p:selectOneMenu value="#{responsavelBean.responsavel.pessoa}"
						effect="fade" converter="convertePessoa">
						<f:selectItem itemLabel="Selecione..." itemValue="" />
						<f:selectItems value="#{pessoaBean.pessoas}" var="pojo"
							itemLabel="#{pojo.pessoCodigo}-#{pojo.pessoNome}"
							itemValue="#{pojo}" />
					</p:selectOneMenu>

					<h:outputText value="Funcao:" />
					<p:selectOneMenu value="#{responsavelBean.responsavel.funcao}"
						effect="fade" converter="converteFuncao">
						<f:selectItem itemLabel="Selecione..." itemValue="" />
						<f:selectItems value="#{funcaoBean.funcaos}" var="pojo"
							itemLabel="#{pojo.funcCodigo}-#{pojo.funcDescricao}"
							itemValue="#{pojo}" />
					</p:selectOneMenu>

					<h:outputText value="Residencial-Bloco:" />
					<p:selectOneMenu value="#{responsavelBean.responsavel.bloco}"
						effect="fade" converter="converteBloco">
						<f:selectItem itemLabel="Selecione..." itemValue="" />
						<f:selectItems value="#{blocoBean.blocos}" var="pojo"
							itemLabel="#{pojo.residencial.resNome}-#{pojo.bloDescricao}"
							itemValue="#{pojo}" />
					</p:selectOneMenu>

					<h:outputText value="Data Inicio:" />
					<p:calendar value="#{responsavelBean.responsavel.respInicio}"
						id="calRespInicio" pattern="dd/MM/yyyy" locale="pt"
						showButtonPanel="true" navigator="true" />

					<h:outputText value="Data Fim:" />
					<p:calendar value="#{responsavelBean.responsavel.respFim}"
						id="calRespFim" pattern="dd/MM/yyyy" locale="pt"
						showButtonPanel="true" navigator="true" />

				</h:panelGrid>
				<p:commandButton value="Salvar"
					actionListener="#{responsavelBean.salvar}" ajax="false" />
				<p:commandButton value="Cancelar" action="responsavel" ajax="false" />
			</h:form>

		</ui:define>

	</ui:composition>

</h:body>
</html>